//-----------------------------------------------------------------------
// <copyright file="CountryDAO.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
	
using System;
using System.Data;
using MIMS.WRS.Entities;
using MyFramework;
using MyFramework.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace MIMS.WRS.Data
{	
	public class CountryDAO : CountryDAOBase
	{
		public CountryDAO()
		{
		}

		public virtual CountryCollection GetCountriesForIDS()
		{            
			try
			{
				Database database = DatabaseFactory.CreateDatabase();
				DBCommandWrapper dbCommandWrapper = database.GetStoredProcCommandWrapper("spCountriesGetListForIDS");
                
				CountryCollection countryCollection = new CountryCollection();
				using (IDataReader reader = DataAccessHelper.ExecuteReader(database, dbCommandWrapper))
				{
					while (reader.Read())
					{
						Country country = CreateCountryFromReader(reader);
						countryCollection.Add(country);
					}
					reader.Close();
				}
				return countryCollection;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new DataAccessException("SR.DataAccessGetCountriesForIDSException", ex);
			}
		}
	}
}
